#include "pch.h"
#include "StrokeStyle.h"
#include <memory>
#include "ErrorCodes.h"
#include "Factories.h"

using namespace Platform;
using namespace DXBase;
using namespace DXBase::D2D;


StrokeStyle::StrokeStyle()
	: properties(D2D1::StrokeStyleProperties())
{
}
Microsoft::WRL::ComPtr<ID2D1StrokeStyle> StrokeStyle::GetNativeStrokeStyle()
{
	if (!style)
	{
		if (dashes)
		{
			std::vector<float> vdashes;
			for each (auto value in dashes)
				vdashes.push_back(value);
			HR2Ex(Factories::GetD2DFactory()->CreateStrokeStyle(properties, &vdashes[0], (UINT32)vdashes.size(), style.GetAddressOf()));
		}
		else
		{
			HR2Ex(Factories::GetD2DFactory()->CreateStrokeStyle(properties, nullptr, 0, style.GetAddressOf()));
		}
	}
	return style;
}
